import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';




class SlidingDeleteDemo extends StatelessWidget {


  //构建30条列表数据
  List<String> items = new List<String>.generate(30, (i) => "列表项 ${i + 1}");

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('滑动删除'),
      ),
      body: Container(
        
        
        child: ListView.builder(
            itemCount: items.length,
            itemBuilder: (context,index){
             final item1 = items[index];

              return Dismissible(
                key: Key(item1),
                //被删除回调
                onDismissed: (direction){
                  items.removeAt(index);
                  Fluttertoast.showToast(msg: '$item1 被删除了');

                },

                child: ListTile(title: Text('$item1'),),
              );
            },

        ),

      ),
    );
  }
}
